#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e6 + 5;

int n, n2;
int a[N];
ll sum[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) a[i + n] = a[i];
  n2 = n * 2;
  rep(i, 1, n2) sum[i] = sum[i - 1] + a[i];
  deque<int> dq;
  dq.push_back(0);
  int ans = 0;
  rep(i, 1, n2 - 1) {
    while (dq.size() && dq.front() + n <= i) dq.pop_front();
    while (dq.size() && sum[dq.back()] >= sum[i]) dq.pop_back();
    dq.push_back(i);
    if (i >= n && sum[dq.front()] >= sum[i - n]) ans++;
  }
  cout << ans;
  return 0;
}